var a = getApp();

Page({
    data: {
        list: [],
        card_id: "",
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(a) {
        this.setData({
            card_id: a.card_id
        }), this.getDate();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多了");
    },
    onShareAppMessage: function() {},
    toGood: function(a) {
        var t = a.target.dataset.id || a.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageA/detail_v2/detail_v2?id=" + t
        });
    },
    getDate: function() {
        var t = this, e = a.getNetAddresss("plugin.business-card.frontend.controllers.trace.trace-history.index");
        e += "&page=1&card_id=" + this.data.card_id, a._getNetWork({
            url: e,
            success: function(a) {
                var e = a.data;
                1 == e.result ? (t.setData({
                    isLoadMore: !0,
                    total_page: e.data.last_page,
                    list: e.data.data
                }), t.data.total_page || t.setData({
                    total_page: 0
                })) : wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    getMoreData: function() {
        var t = this;
        if (this.setData({
            isLoadMore: !1
        }), !(this.data.page >= this.data.total_page)) {
            var e = this.data.page + 1;
            this.setData({
                page: e
            });
            var o = a.getNetAddresss("plugin.business-card.frontend.controllers.trace.trace-history.index");
            o += "&page=" + this.data.page + "&card_id=" + this.data.card_id, a._getNetWork({
                url: o,
                success: function(a) {
                    var e = a.data;
                    if (t.setData({
                        isLoadMore: !0
                    }), 1 == e.result) {
                        var o = e.data.data.concat(t.data.list);
                        t.setData({
                            list: o
                        });
                    } else {
                        wx.showToast({
                            title: e.msg,
                            icon: "none"
                        });
                        var s = t.data.page - 1;
                        t.setData({
                            isLoadMore: !1,
                            page: s
                        });
                    }
                },
                fail: function(a) {
                    console.log(a);
                }
            });
        }
    }
});